package com.ysx.oa.teacher.service.impl;
import com.ysx.oa.clazz.bean.ClazzBean;
import com.ysx.oa.clazz.bean.ClazzStudentTeacherBean;
import com.ysx.oa.clazz.dao.ClazzDao;
import com.ysx.oa.clazz.dao.ClazzStudentTeacherDao;
import com.ysx.oa.delay.bean.DelayBean;
import com.ysx.oa.holiday.dao.HolidayDao;
import com.ysx.oa.resume.dao.QuestionDao;
import com.ysx.oa.role.bean.RoleBean;
import com.ysx.oa.role.dao.UserRoleDao;
import com.ysx.oa.teacher.bean.TeacherBean;
import com.ysx.oa.teacher.dao.TeacherDao;
import com.ysx.oa.teacher.dto.MyDto;
import com.ysx.oa.teacher.service.TeacherService;
import com.ysx.oa.user.bean.UserBean;
import com.ysx.oa.user.dao.UserDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;


import java.util.List;
/**
 * @author 袁海华
 * @date 2021/11/23 9:31
 */
@Service
public class TeacherServiceImpl implements TeacherService {
    @Autowired
    private TeacherDao dao;
    @Autowired
    private UserDao userDao;
    @Autowired
    private ClazzDao clazzDao;
    @Autowired
    private HolidayDao holidayDao;
    @Autowired
    private QuestionDao questionDao;
    @Autowired
    private UserRoleDao userRoleDao;
    @Autowired
    private ClazzStudentTeacherDao clazzStudentTeacherDao;



    @Override
    public List<MyDto> findTeacherInforByClazzType(Integer type) {
        return dao.findTeacherInforByClazzType(type);
    }


    @Override
    public List<UserBean> findStudentOrTeacherByNotClass(RoleBean roleBean) {

        return userDao.findStudentOrTeacherByNotClass(roleBean);
    }



    @Override
    public int add(TeacherBean teacherBean) {

        return dao.insert(teacherBean);
    }
    @Override
    public int deleteById(Integer teacherId) {
        TeacherBean teacherBean = new TeacherBean();
        teacherBean.setTeacherId(teacherId);
        return dao.delete(teacherBean);
    }
    @Override
    public int updateById(TeacherBean teacherBean) {
        return dao.updateByPrimaryKey(teacherBean);
    }

    @Override
    public int updateTeacherInforByTeacherId(UserBean userBean) {
        userDao.updateByPrimaryKey(userBean);
        return 1;
    }

    @Override
    public List<Integer> findAllTeacherIdByRoleId(Integer roleId) {
        List<Integer> rs = dao.findAllTeacherIdByRoleId(roleId);
        return rs;
    }

    @Override
    public int addClazzByTeacherId(ClazzStudentTeacherBean clazzStudentTeacherBean) {
       return dao.addClazzByTeacherId(clazzStudentTeacherBean);

    }




    @Override
    public TeacherBean findById(Integer teacherId) {
        TeacherBean teacherBean= new TeacherBean();
        teacherBean.setTeacherId(teacherId);
        return dao.selectOne(teacherBean);
    }
    @Override
    public List<DelayBean> findLateStudentInforByTeacherId(Integer teacherId) {
        List<DelayBean> rs = dao.findLateStudentInforByTeacherId(teacherId);
        return rs;
    }
    @Override
    public List<Integer> findStudentIdByTeacherId(Integer teacherId) {
        Integer classId = dao.findClazzIdByTeacherId(teacherId);
        return dao.findALLStudentIdByClazzId(classId);
    }
    //    @Override
//    public int addStudentByTeacherId(Integer teacherId) {
//        TeacherBean teacherBean= new TeacherBean();
//        teacherBean.setTeacherId(teacherId);
//
//        return 1;
//    }

//    @Override
//    public ArrayList<QuestionEntity> findQuestionsByTeacherId(Integer teacherId) {
//        Integer clazzIdByTeacherId = dao.findClazzIdByTeacherId(teacherId);
//        return questionDao.selectQuestionEntityByClassId(clazzIdByTeacherId);
//    }

//    @Override
//    public int addClazzByTeacherId(TeacherBean teacherBean) {
//        return 1;
//    }
}



